(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/SoundSetup.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'd5956MbVZFHu4mIycCdcasX', 'SoundSetup', __filename);
// Script/SoundSetup.js

"use strict";

// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

var self = void 0;
var AU = require("AudioUtils");
cc.Class({
    extends: cc.Component,

    properties: {
        musicSolid: { //音乐滑块
            default: null,
            type: cc.Slider
        },
        effectSolid: { //音效滑块
            default: null,
            type: cc.Slider
        },
        musicChk: { //音乐开关
            default: null,
            type: cc.Toggle
        },
        effectChk: { //音效开关
            default: null,
            type: cc.Toggle
        }
    },

    _init: function _init() {
        var m = AU.inst.getMusicVolume1(); //回显存储本地音量(音乐)大小
        self.musicSolid.progress = m;
        self._updateMusicVolume(m);
        self.musicChk.isChecked = AU.inst.getSwitchMusic(); //设置音乐开关

        var e = AU.inst.getEffectVolume1(); //回显存储本地音量(音效)大小
        self.effectSolid.progress = e;
        self._updateEffectVolume(e);
        self.effectChk.isChecked = AU.inst.getSwitchEffect(); //设置音效开关
    },

    onLoad: function onLoad() {
        self = this;
        self._init();
    },


    _updateMusicVolume: function _updateMusicVolume(progress) {
        AU.inst.setMusicVolume(progress);
        //console.log(progress);
    },
    onSliderMusicEvent: function onSliderMusicEvent(sender, eventType) {
        self._updateMusicVolume(sender.progress);
    },

    _updateEffectVolume: function _updateEffectVolume(progress) {
        AU.inst.setEffectVolume(progress);
    },
    onSliderEffectEvent: function onSliderEffectEvent(sender, eventType) {
        self._updateEffectVolume(sender.progress);
    },

    /**
     * 音乐开关
     * @param {Object} title
     * @param {Object} label
     * @param {Object} toggle
     */
    onMusicToggleEvent: function onMusicToggleEvent(toggle) {
        //console.log("toggle:"+toggle.isChecked);
        if (toggle.isChecked) {
            AU.inst.switchMusicFunc(true);
            if (!AU.inst.isMusicPlaying()) {
                //重新打开游戏后,打开声音执行setResumeMusic()恢复播放无效,需要重新播放
                AU.inst.playMusic(MUSIC_SPACE_TRIP, true);
            }
        } else {
            AU.inst.switchMusicFunc(false);
        }
    },

    /**
     * 音效开关
     * @param {Object} title
     * @param {Object} label
     * @param {Object} toggle
     */
    onEffectToggleEvent: function onEffectToggleEvent(toggle) {
        //console.log("toggle:"+toggle.isChecked);
        if (toggle.isChecked) {
            AU.inst.switchEffectFunc(true);
        } else {
            AU.inst.switchEffectFunc(false);
        }
    },

    start: function start() {}
}

// update (dt) {},
);

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=SoundSetup.js.map
        